package edu.pku.sei.act.ctrl.command;

import org.eclipse.gef.commands.Command;

import edu.pku.sei.act.model.common.ArchiModel;
import edu.pku.sei.act.model.mote.Mote;
import edu.pku.sei.act.model.mote.OuterModelElement;

public class DeleteBaseCommand extends Command{
	
	private Mote model;
	private OuterModelElement element;

	public DeleteBaseCommand(OuterModelElement element) {

		this.element = element;
		if (element.getContainer() instanceof ArchiModel) {
			model = (Mote) element.getContainer();
		}
	}

	public boolean canExecute() {
		return element != null &&  model != null;
	}

	public void execute() {
		if (model != null) {
			//model.getRootElements().remove(element);
		}
		element.setContainer(null);
	}

	public void undo() {
		if (model != null) {
			element.setContainer(model);
			//model.getRootElements().add(element);
		}
	}

}
